#test
from flask import Flask
from flask import request
from tools.data import mysql_tool


app = Flask(__name__)

@app.route('/hello/login',methods = ['GET'])
def login():
    user_name=request.args['user_name']
    pwd=request.args['pwd']
    print(user_name)
    print(pwd)
    sql="SELECT * from t_user_user t where t.user_name='%s' and pwd='%s' and status=0 and active_time < now()"%(user_name,pwd)
    print(sql)
    conn = {
        "host": "www.guoyasoft.com",
        "port": 3306,
        "user": "stu",
        "password": "GYWiki2017",
        "database": "guoya_virtual_mall",
        "charset": "utf8"
    }
    db=mysql_tool.connect(**conn)
    rlt=mysql_tool.query_one(sql,db)
    print(rlt)
    if rlt==None:
        return "用户不存在"
    else:
        tab='<ui><body><table border="1px solid black"><tr><td>用户名</td><td>密码</td></tr><tr><td>%s</td><td>%s</td></tr></table></body></ui>'%(user_name,pwd)
        return tab


if __name__ == '__main__':
   app.run('127.0.0.1',5011,debug=True)